package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    /**
     * 根据openid查询数据库中的用户
     *
     * @param openid
     * @return user
     * @info 执行sql语句根据openid查询user表中是否存在对应的用户
     */
    @Select("select * from user where openid=#{openid}")
    public User getUserByOpenid(String openid);

    /**
     * 插入user用户
     */
    @Insert("insert into user (openid,create_time) values (#{openid},#{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    public Long insertUser(User user);
}
